﻿import QtQuick 2.0

import "../components"



// 暂停后需要输入密码来继续实验
CustomPopupBox {

    id: root

    signal accepted()

    height: 260*dp; width: 360*dp

    property string pswd: ""

    onVisibleChanged: {
        pswd = CExeConfig.passwordRead()
        edit_pswd.redBorder = false
        edit_pswd.setText("")
    }


    contentItem: Item{
        CustomInputText{
            id: edit_pswd
            title: "密码"
            y: 20*dp
            anchors.horizontalCenter: parent.horizontalCenter
            editWidth: 200*dp
        }
        Row{
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 30*dp
            spacing: 15*dp
            CustomButton{
                defaultMode2: true
                title: "取消"
                onClicked: {
                    root.close()
                }
            }CustomButton{
                defaultMode1: true
                title: "确定"
                onClicked: {
                    if(edit_pswd.getText() === pswd){
                        root.accepted()
                        root.close()
                        gPauseNeedPassword = false
                    }else{
                        edit_pswd.redBorder = true
                        edit_pswd.redInfo = "密码错误"
                    }
                }
            }
        }
    }


}
